﻿Imports System.Reflection

Namespace SqlCe35
    Public Class ColumnDefinitionAttributeFactory
        Inherits Kairyu.Extensions.DDL.ColumnDefinitionAttributeFactory

        Public Overrides Function GetColumnType(def As ColumnDefinitionAttribute, t As Type) As String
            If t.Equals(GetType(Boolean)) Then
                Return "bit"
            ElseIf t.Equals(GetType(Byte())) Then
                Return "image"
            ElseIf t.Equals(GetType(Char)) Then
                Return "nchar"
            ElseIf t.Equals(GetType(DateTime)) Then
                Return "datetime"
            ElseIf t.Equals(GetType(Decimal)) Then
                Return "decimal"
            ElseIf t.Equals(GetType(Double)) Then
                Return "float"
            ElseIf t.Equals(GetType(Int32)) OrElse t.IsEnum Then
                Return "int"
            ElseIf t.Equals(GetType(Int64)) Then
                Return "bigint"
            ElseIf t.Equals(GetType(Int16)) Then
                Return "smallint"
            ElseIf t.Equals(GetType(Single)) Then
                Return "real"
            ElseIf t.Equals(GetType(String)) Then
                If def.IsStaticLength Then
                    Return "nchar({0})"
                Else
                    Return "nvarchar({0})"
                End If
            Else
                Return "sql_variant"
            End If
        End Function
    End Class
End Namespace